Entry—Fix inverted movements by arrow keys in RTL
authorDaniel Boles <dboles@src.gnome.org>
Sat, 18 Feb 2017 22:50:00 +0000 (22:50 +0000)
committerDaniel Boles <dboles@src.gnome.org>
Sun, 19 Feb 2017 12:39:05 +0000 (12:39 +0000)
Using Ctrl + left/right to skip between words, or left/right to cancel a
selection, were causing movement on the screen in the opposite direction
of the glyph on the key. This was surprising and awful UX for RTL users.

This is based on a patch covering the former case by:
Author:    Ori Avtalion <ori@avtalion.name>
Date:      Tue Apr 20 08:06:23 2010 +0000

https://bugzilla.gnome.org/show_bug.cgi?id=136059

gtk/gtkentry.c

index ab698ff1208ac9d3f6ef0e89bf66f3b57a011ffe..49f8d8f7592345c0e95665eb7113a9a902b01fd1 100644 (file)
@@ -5177,8 +5177,11 @@ gtk_entry_move_cursor (GtkEntry       *entry,
              new_pos = current_x > bound_x ? priv->current_pos : priv->selection_bound;
            break;
          }
-       case GTK_MOVEMENT_LOGICAL_POSITIONS:
        case GTK_MOVEMENT_WORDS:
+          if (priv->resolved_dir == PANGO_DIRECTION_RTL)
+            count *= -1;
+          /* Fall through */
+       case GTK_MOVEMENT_LOGICAL_POSITIONS:
          if (count < 0)
            new_pos = MIN (priv->current_pos, priv->selection_bound);
          else
@@ -5228,6 +5231,8 @@ gtk_entry_move_cursor (GtkEntry       *entry,
             }
          break;
        case GTK_MOVEMENT_WORDS:
+          if (priv->resolved_dir == PANGO_DIRECTION_RTL)
+            count *= -1;
          while (count > 0)
            {
              new_pos = gtk_entry_move_forward_word (entry, new_pos, FALSE);